#!/usr/bin/env python 

import inkex
import simplestyle, sys
import andengineutils

class AndEngine(inkex.Effect):
    def __init__(self):
        """
        Constructor.
        Defines the "--what" option of a script.
        """
        # Call the base class constructor.
        inkex.Effect.__init__(self)
        
        # Define string option "--what" with "-w" shortcut and default value "World".
        self.OptionParser.add_option("--mass", action="store", type="float", dest="mass", default=0, help="mass")
        self.OptionParser.add_option("--masscenterx", action="store", type="float", dest="masscenterx", default=0, help="masscenter x")
        self.OptionParser.add_option("--masscentery", action="store", type="float", dest="masscentery", default=0, help="masscenter y")
        self.OptionParser.add_option("--rotationalinertia", action="store", type="float", dest="rotationalinertia", default=0, help="rotational inertia")
        self.OptionParser.add_option("--velocityx", action="store", type="float", dest="velocityx", default=0, help="velocity x")
        self.OptionParser.add_option("--velocityy", action="store", type="float", dest="velocityy", default=0, help="velocity y")
        self.OptionParser.add_option("--angularvelocity", action="store", type="float", dest="angularvelocity", default=0, help="angular velocity")
        self.OptionParser.add_option("--accelerationx", action="store", type="float", dest="accelerationx", default=0, help="acceleration x")
        self.OptionParser.add_option("--accelerationy", action="store", type="float", dest="accelerationy", default=0, help="acceleration y")
        
    def effect(self):
        for id, node in self.selected.iteritems():
            
            andengineutils.creatOrDelete("andengine-mass", node, self.options.mass, 0)
            andengineutils.creatOrDelete("andengine-masscenterx", node, self.options.masscenterx, 0)
            andengineutils.creatOrDelete("andengine-masscentery", node, self.options.masscentery, 0)
            andengineutils.creatOrDelete("andengine-rotationalinertia", node, self.options.rotationalinertia, 0)
            
            andengineutils.creatOrDelete("andengine-velocityx", node, self.options.velocityx, 0)
            andengineutils.creatOrDelete("andengine-velocityy", node, self.options.velocityy, 0)
            andengineutils.creatOrDelete("andengine-angularvelocity", node, self.options.angularvelocity, 0)
            andengineutils.creatOrDelete("andengine-accelerationx", node, self.options.accelerationx, 0)
            andengineutils.creatOrDelete("andengine-accelerationy", node, self.options.accelerationy, 0)
        
if __name__ == '__main__':
    e = AndEngine()
    e.affect()